package fun.qu_an.minecraft.fabric.fzbbl.mixin;

import fun.qu_an.minecraft.fabric.fzbbl.api.IPistonCache;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;

import java.util.HashMap;

@Mixin(ServerWorld.class)
public class ServerWorldMixin implements IPistonCache {
	private final HashMap<BlockPos, ServerPlayerEntity> pistonCache = new HashMap<>();

	@Override
	public void putPistonCache(BlockPos pos, ServerPlayerEntity player) {
		pistonCache.put(pos, player);
	}

	@Override
	public ServerPlayerEntity getPistonCache(BlockPos pos) {
		return pistonCache.get(pos);
	}

	@Override
	public void clearPistonCache() {
		pistonCache.clear();
	}
}
